#include("/common/_layout.html")
#@layout()
#define layoutHead()
	<title>圆所介绍</title>
	<style>
		.teacher-add{ display: none; }
		.teacher-label{ }
	</style>
#end
#define layoutBody()
	<body>
		<div class="page-content-wrap">
				<form class="layui-form" lay-filter="formedit">
					<input type="hidden" name="org_id">
					<div class="layui-tab" style="margin: 0;">
						<div class="layui-tab-content">
							<div class="layui-tab-item"></div>
							<div class="layui-tab-item layui-show">
								<div class="layui-form-item">
									<textarea class="layui-textarea layui-hide" id="org_desc" name="org_desc" lay-verify="content"></textarea>
								</div>
							</div>
						</div>
					</div>
					<div class="layui-form-item" style="padding-left: 10px;">
						<div class="layui-input-block">
							<button class="layui-btn layui-btn-normal" lay-submit lay-filter="formDemo">立即提交</button>
							
						</div>
					</div>
				</form>
		</div>
		<script>
			var article_desc_edit_idx;
			
			layui.use(['form', 'layer', 'laytpl', 'upload', 'layedit'], function() {
				var form = layui.form();
				var layer = layui.layer;
				var laytpl = layui.laytpl,
					layedit = layui.layedit;
					
				// 编辑器图片上传,放在build前面
				layedit.set({
				  uploadImage: {
					url: '/api/eduorg/file/upload' 
					,type: '' //默认post
				  }
				});
				
				function initDescEditor(){
					//创建一个编辑器
					article_desc_edit_idx = layedit.build('org_desc', {
						tool: ['strong' //加粗
							, 'italic' //斜体
							, 'underline' //下划线
							, 'del' //删除线
							, '|' //分割线
							, 'left' //左对齐
							, 'center' //居中对齐
							, 'right' //右对齐
							, 'link' //超链接
							, 'unlink' //清除链接
							, 'image' //插入图片
						],
						height: 400
					});
				}
				
				// 表单验证
				form.verify({});

				//监听提交
				form.on('submit(formDemo)', function(formData){
					//console.log(formData.field);
					formData.field.org_desc = layedit.getContent(article_desc_edit_idx);
					sendPost("/api/eduorg/org/saveDesc", formData.field, function(res) {
						layer.alert(res.msg, {
							title: '信息提示'
						}, function(idx){
							layer.close(idx);
						});
					});
					return false;
				});

				// 页面初始化
				function page_init(){
					var id = getUrlParam('id');

					// 加载初始化编辑数据
					sendGet("/api/eduorg/org/getOrg", {}, function(res) {
						//console.log(res);
						// 初始化编辑数据
						if (res.hasOwnProperty("orginfo")) {
							//console.log(res.orginfo.area_names);
							$("#org_desc").val(res.orginfo.org_desc);
							initDescEditor();
						}
						form.render();
					});
				}

				initDescEditor();
				page_init();
			});
			
			
					
		</script>
	</body>

#end